home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / os2 / te2pro20.zip / TPHOST.SCR < prev    next >
Text File  |  1996-05-31  |  14KB  |  570 lines

  1. /* TE/2 Pro! host Mode Script */
  2. signal on syntax
  3.  
  4. /* Control variable */
  5. HostModeActive = 1
  6.  
  7. /* Handy character constants */
  8. lf          = D2C(10)
  9. ff          = D2C(12)
  10. cr          = D2C(13)
  11. esc         = D2C(27)
  12. crlf        = cr||lf
  13.  
  14. /* Modem initialization.  Edit these for your modem. */
  15. ModemInit   = 'ATZ'||cr
  16. AnswerCall  = 'ATA'||cr
  17. MaximumBaud = 57600
  18. StdParity   = 'none'
  19. StdWordLen  = 8
  20. StdStopBits = 1
  21. MatchBaud   = 0
  22. DevHandle   = 0 /* This is filled in at startup */
  23.  
  24. /* Files and paths.  Edit these for your system. */
  25. HomePath    = 'C:\te2pro\host'
  26. PublicPath  = 'C:\te2pro\host\dl'
  27. HostULPath  = 'C:\te2pro\host\ul'
  28. UserFile    = 'C:\te2pro\host\user.tph'
  29.  
  30. /* Control variable.  None of these are active at present, they are */
  31. /* reserved for future use.                                         */
  32. WatchUser   = 1
  33. HotKeys     = 1
  34. LocalLogin  = 0
  35.  
  36. /* Timing for WatForCall routine. WaitCallD1 is timeout value while */
  37. /* waiting for "RING", WaitCallD2 is sleep time between waits.      */
  38. WaitCallD1  = 60
  39. WaitCallD2  = 1
  40.  
  41. /* Set MatchBaud to 1 if your modem needs to match baud to the      */
  42. /* caller (2400bps modems) or set to 0 otherwise.  CallerBaud       */
  43. /* records the caller's baud if MatchBaud is 1 or is set to         */
  44. /* MaximumBaud otherwise.                                           */
  45. MatchBaud   = 0
  46. CallerBaud  = 0
  47.  
  48. /* Color attributes for menus, etc. */
  49. DfltAttr    = esc||'[36;0m'
  50. BoldOn      = esc||'[33;1m'
  51. BoldOff     = DfltAttr
  52. WarnOn      = esc||'[37;1m'
  53. WarnOff     = DfltAttr
  54. ClrTerm     = esc||'[2J'
  55.  
  56. /* Menus */
  57. Menu.       = ''
  58. Menu.0      = 4
  59. Menu.1      = '[F]ile directory'
  60. Menu.2      = '[D]ownload'
  61. Menu.3      = '[U]pload'
  62. Menu.4      = '[G]oodbye'
  63.  
  64. XMenu.      = ''
  65. XMenu.0     = 6
  66. XMenu.1     = '[X]modem'
  67. XMenu.2     = 'Xmodem-[1]K'
  68. XMenu.3     = '[Y]modem'
  69. XMenu.4     = 'Ymodem-[G]'
  70. XMenu.5     = '[Z]modem'
  71. XMenu.6     = '[ENTER] = return to main menu.'
  72.  
  73. /* User list and current user */
  74. Users.      = ''
  75. Users.0     = 0
  76. CurUser     = 0
  77. UserOK      = 0
  78.  
  79.  
  80. /* ---------------------------------------------------------------------
  81.    -- FaxWorks interoperability section
  82.       FaxAns  is a boolean flag to enable or disable answering of
  83.               incoming fax calls.  Set to 1 to enable, 0 to disable.
  84.       FaxPgm  is the full path to your copy of the FaxWorks executable
  85.               file.
  86.       FaxInit is your modem setup to enable answering of both fax and
  87.               data calls.  For Class 1 fax modems, this would be
  88.               "AT+FAE=1"||cr.  For Class 2 and 2.0 modems, this would be
  89.               "AT+FAA=1"||cr.
  90. ------------------------------------------------------------------------ */
  91. FaxAns  = 0
  92. FaxPgm  = 'd:\comm\pmfax\pmfax.exe'
  93. FaxInit = 'AT+FAE=1'||cr
  94. /* --------------------------------------------------------------------- */
  95.  
  96.  
  97. Main:
  98.   call RxFuncAdd 'SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs'
  99.   call SysLoadFuncs
  100.   call ReadUserList
  101.   SavedPath = directory()
  102.   'query devicehandle DevHandle'
  103.   do while HostModeActive = 1
  104.     'cls'
  105.     say 'TE/2 Pro Host Mode Script'
  106.     say
  107.     say
  108.     call InitModem
  109.     call WaitForCall
  110.     if HostModeActive = 1 then call HostMode
  111.   end
  112.   call directory SavedPath
  113.   exit 0
  114.  
  115.  
  116.  
  117. ReadUserList:
  118.   r = stream(UserFile, 'C', 'open read')
  119.   if r = 'READY:' then
  120.     do
  121.       do while lines(UserFile) > 0
  122.         r = linein(UserFile)
  123.         if length(r) > 0 then
  124.           do
  125.             parse var r lv ',' ln ',' fn ',' pw ',' cf ',' ct
  126.             if length(ct) > 0 then
  127.               do
  128.                 i = Users.0 + 1
  129.                 Users.i.Level     = lv
  130.                 Users.i.LastName  = ln
  131.                 Users.i.FirstName = fn
  132.                 Users.i.Password  = pw
  133.                 Users.i.Color     = translate(cf)
  134.                 Users.i.Lines     = ct
  135.                 Users.0 = i
  136.               end
  137.           end
  138.       end
  139.       call stream UserFile, 'C', 'close'
  140.     end
  141.   else
  142.     say 'Cannot read User File:' UserFile '(rescode='r')'
  143.   return
  144.  
  145.  
  146.  
  147. InitModem:
  148.   'set baud'     MaximumBaud
  149.   'set parity'   StdParity
  150.   'set databits' StdWordLen
  151.   'set stopbits' StdStopBits
  152.   'transmit' ModemInit
  153.   'sleep 2'
  154.   if FaxAns = 1 then
  155.     do
  156.       'transmit' FaxInit
  157.       'sleep 2'
  158.     end
  159.   return
  160.  
  161.  
  162.  
  163. WaitForCall:
  164.   say 'Waiting for call...'
  165.   do forever
  166.     say date() time() 'Waiting...'
  167.     'wait' WaitCallD1 'RING'
  168.     WaitResult = rc
  169.     select
  170.       when WaitResult = 1 then
  171.         do
  172.           'rcvcapture true'
  173.           'transmit' AnswerCall
  174.           GotFax = 0
  175.           if FaxAns = 1 then
  176.             do 5
  177.               'receive CR255 10 NOECHO'
  178.               ln = FixRmtInp(rc)
  179.               select
  180.                 when translate(word(ln, 1)) = 'DATA' then
  181.                   leave
  182.                 when translate(word(ln, 1)) = 'FAX' then
  183.                   do
  184.                     GotFax = 1
  185.                     leave
  186.                   end
  187.                 otherwise
  188.                   nop
  189.               end
  190.             end
  191.           if GotFax = 1 then
  192.             do
  193.               'rcvcapture false'
  194.               call ReceiveFax
  195.               iterate
  196.             end
  197.  
  198.           GotConnect = 0
  199.           do 5
  200.             'receive CR255 10 NOECHO'
  201.             ln = FixRmtInp(rc)
  202.             if translate(word(ln, 1)) = 'CONNECT' then
  203.               do
  204.                 GotConnect = 1
  205.                 leave
  206.               end
  207.           end
  208.           'rcvcapture false'
  209.           if GotConnect = 1 then
  210.             do
  211.               if MatchBaud = 1 then
  212.                 do
  213.                   tmpstrg = substr(ln, wordindex(ln, 2))
  214.                   do i = 1 to length(tmpstrg)
  215.                     if datatype(substr(tmpstrg)) \= 'NUM' then
  216.                       do
  217.                         tmpstrg = substr(tmpstrg, i)
  218.                         leave
  219.                       end
  220.                   end
  221.                   CallerBaud = tmpstrg
  222.                   'set baud' CallerBaud
  223.                 end
  224.               else
  225.                 CallerBaud = MaximumBaud
  226.               leave
  227.             end
  228.         end
  229.       when WaitResult = 10000 then
  230.         do
  231.           AskYN.Text  = 'Okay to exit host mode?'
  232.           AskYN.Title = 'TE/2 Pro! Host Mode'
  233.           AskYN.Style = X2D('4014') /* MB_MOVEABLE|MB_ICONQUESTION|MB_YESNO */
  234.           'messageboxv askyn'
  235.           if rc = 6 /* MBID_YES */ then
  236.             do
  237.               HostModeActive = 0
  238.               leave
  239.             end
  240.         end
  241.       otherwise
  242.         'sleep' WaitCallD2
  243.     end
  244.   end
  245.   return
  246.  
  247.  
  248.  
  249. HostMode:
  250.   'sleep 3'
  251.   'transmit "'ff||crlf'Hello Caller...'crlf'"'
  252.   say
  253.   say date() time() 'Answered call'
  254.   'rcvcapture true'
  255.   call GetLogin
  256.   MenuLevel = 'MAIN'
  257.   if CurUser > 0 & UserOK > 0 then
  258.     do forever
  259.       'query carrier'
  260.       if rc = 1 then
  261.         do
  262.           call ShowMenu MenuLevel
  263.           call ExecMenu MenuLevel
  264.         end
  265.       else
  266.         leave
  267.     end
  268.   else
  269.     'hangup'
  270.   'rcvcapture false'
  271.   return
  272.  
  273.  
  274.  
  275. GetLogin:
  276.   CurUser = 0
  277.   UserOK  = 0
  278.   do 4
  279.     'transmit "'crlf'Enter FIRST and LAST name: '
  280.     'receive CR255 120 ECHO'
  281.     r = FixRmtInp(rc)
  282.     say
  283.     if length(r) > 0 then
  284.       do
  285.         parse upper var r fn ln
  286.         do i = 1 to Users.0
  287.           say fn ln 'vs.' Users.i.FirstName Users.i.LastName
  288.           if translate(Users.i.FirstName) = fn & translate(Users.i.LastName) = ln then
  289.             do
  290.               CurUser = i
  291.               leave
  292.             end
  293.         end
  294.         if CurUser > 0 then
  295.           leave
  296.         else
  297.           'transmit "'crlf'Could not locate username: 'r'"'
  298.       end
  299.   end
  300.   if CurUser > 0 then
  301.     do 4
  302.       'transmit "'crlf'Enter password: '
  303.       'receive CR255 120 NOECHO'
  304.       r = FixRmtInp(rc)
  305.       if length(r) > 0 then
  306.         do
  307.           if translate(Users.CurUser.Password) = translate(r) then
  308.             do
  309.               UserOK = 1
  310.               leave
  311.             end
  312.           els